<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
		<meta http-equiv="Cache-Control" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<title>覆盖延伸-待处理任务</title>
		<link rel="stylesheet" type="text/css" href="../scripts/ext2.2.1/resources/css/ext-all.css" />
		<script type="text/javascript" src="../scripts/ext2.2.1/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="../scripts/ext2.2.1/ext-all.js"></script>
		<script type="text/javascript" src="../scripts/ext2.2.1/source/locale/ext-lang-zh_CN.js"></script>
		<script type="text/javascript" src="../scripts/hxcy/hxcy-util.js"></script>
		<script type="text/javascript" src="../scripts/hxcy/hxcy-cmp.js"></script>
		<script type="text/javascript">
		
			function toProcess(id, name, activity) {
				var url = "workflow/task!process.action?id=" + id;
				Hxcy.CmpMgr.showTab({
					id: "iframe-fgys-running-task-" + id,
					closable: true,
					title: name + "-" + activity,
					xtype: "iframe",
					url: url
				});
			}
		
			var win;
			
			function showWindow(id) {
				win = new Ext.Window({
					id: "task_process",
					modal: true,
					title: '任务处理 ',
					layout: 'fit',
					width: 1000,
					height: 450,
					resizable: false,
					html: "<iframe frameborder='0' width='100%' height='100%' src='../workflow/task!process.action?id=" + id + "'</iframe>",
					listeners: {
						close: refresh
					}
				});
				win.show();
			}
			
			function refresh() {
				win.hide();
				grid.getStore().load();
			}
		
			function toProcess(id, name, activity) {
				var url = "workflow/task!process.action?id=" + id;
				Hxcy.CmpMgr.showTab({
					id: "iframe-fgys-running-task-" + id,
					closable: true,
					title: name + "-" + activity,
					xtype: "iframe",
					url: url
				});
			}

			function toView(id, name) {
				var url = "workflow/task!view.action?id=" + id;
				Hxcy.CmpMgr.showTab({
					id: "iframe-fgys-view-" + id,
					closable: true,
					title: name,
					xtype: "iframe",
					url: url
				});
			}
			
			var gridStore = new Ext.data.Store({
				proxy: new Ext.data.HttpProxy({
					url: "../workflow/task!findRunningTask.action",
					method: "GET"
				}),
				reader: new Ext.data.JsonReader({
					fields: ["id", "processInstanceName", "activity", "activationTime"], 
					root: "rows", 
					id: "id",
					totalProperty: "total"
				})
			});
			
			var recordStart = 0;
			var grid = new Ext.grid.GridPanel({
				id: "grid",
				region: "center",
				autoScroll: true,
				margins: "4, 4, 4, 4",
				stripeRows: true,
				enableColumnHide: true,
				store: gridStore,
				loadMask: true,
				sm:new Ext.grid.RowSelectionModel({singeSelect:true}),
				columns: [
					new　Ext.grid.RowNumberer({
						header: "序号",
						width: 40,
						renderer: function(value, metaData, record, rowIndex) {
							return　recordStart + 1　+　rowIndex;
						}
					}), {
						header: "项目名称",
						dataIndex: "processInstanceName"
					}, {
						header: "节点",
						dataIndex: "activity",
						align: "center",
						renderer: function(value, metaData, record, rowIndex) {
							return "<font color='red'>" + value + "</font>";
						}
					}, {
						header: "开启时间",
						dataIndex: "activationTime",
						align: "center"
					}, {
						header: "操作",
						dataIndex: "id",
						align: "center",
						renderer: function(value, metaData, record, rowIndex) {
							return　"<a href=\"javascript:showWindow(" + value + ");\">处理</a> | <a href=\"javascript:toView('" + value + "', '" + record.data.processInstanceName + "');\">查看</a>";
						}
					}
				],
				viewConfig: {
					forceFit: true
				},
				bbar: new Ext.PagingToolbar({
					store: gridStore,
					pageSize: 20,
					displayInfo: true,
					beforePageText: "第",
					afterPageText: "/ {0}页",
					firstText: "首页",
					prevText: "上一页",
					nextText: "下一页",
					lastText: "末页",
					refreshText: "刷新",
					emptyMsg: "没有相关记录！",
					displayMsg: "当前显示第 {0} ~ {1} 条记录，总计 {2} 条记录",
					doLoad: function(start) {
					 	recordStart = start;
					 	this.store.load({params: {start: start, limit: this.pageSize}});
					}
				}),
				tbar: [
					"项目名称：",
					{
						xtype: "textfield",
						id: "content",
						enableKeyEvents: true,
						listeners: {
							specialkey: function(field, e) {
								if (e.getKey() == Ext.EventObject.ENTER) {
									search(this.getValue());
								}
							}
						}  
					},
					" ",
					{
						text: "查询", 
						handler: function() {
							search(grid.el.dom.document.getElementById("content").value);
						}
					}
				],
				listeners:{
					rowdblclick: function(){
						var record = grid.getSelectionModel().getSelected();
						showWindow(record.id);
					}
				}
			});
			
			
			
			/**查找*/
			function search(content) {
				if (content) {
					content = content.replace(/^\s+|\s+$/g, "");
				}
				gridStore.baseParams = {processInstanceName: content};
				gridStore.load({params: {processName: "室内分布建设", start: 0, limit: 20}});
			}
			
			Ext.QuickTips.init();
			Ext.onReady(function() {
				gridStore.load({params: {processName: "室内分布建设", start: 0, limit: 20}});
				new Ext.Viewport({
					layout: "border",
					border: false,
					items: [grid]
				});
			});
		</script>
	</head>
	<body>
	</body>
</html>